package stars.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class StarParameters {
	
	private HashMap<String, StarTypeData> parameters = new HashMap<String, StarTypeData>();
	
	private HashMap<String, Double> youngProbabilities = new HashMap<String, Double>();
	private HashMap<String, Double> averageProbabilities = new HashMap<String, Double>();
	private HashMap<String, Double> oldProbabilities = new HashMap<String, Double>();
	
	private HashMap<String, ArrayList<Float>> colors = new HashMap<String, ArrayList<Float>>();
	private HashMap<String, String> colorNames = new HashMap<String, String>();
	
	private ArrayList<String> entries = new ArrayList<String>();
	
	
	
	public ArrayList<String> getEntries() {
		return this.entries;
	}
	
	public void addParameter(String param, StarTypeData value) {
		parameters.put(param, value);
		entries.add(param);
		
		youngProbabilities.put(value.getName(), value.getYoungProb());
		averageProbabilities.put(value.getName(), value.getAverageProb());
		oldProbabilities.put(value.getName(), value.getOldProb());
		
		colors.put(value.getName(), value.getRGBColorVals());		
		colorNames.put(value.getName(), value.getColor());
	}
	
	public StarTypeData getParameter(String param) {
		return parameters.get(param);
	}
	
	public HashMap<String, StarTypeData> getAllParameters() {
		return this.parameters;
	}
	
	public void setParameters(HashMap<String, StarTypeData> parameters) {
		this.parameters.clear();
		this.parameters.putAll(parameters);
		
		for (Map.Entry<String, StarTypeData> entry : parameters.entrySet()) {
			entries.add(entry.getKey());
		}
	}
	
	
	
	
	public double getProbability(String param, String age) {
		if (age.equalsIgnoreCase("young")) {
			return youngProbabilities.get(param);
		}
		else if (age.equalsIgnoreCase("average")) {
			return averageProbabilities.get(param);
		}
		else 
			return oldProbabilities.get(param);
	}
	
	public HashMap<String, Double> getAllProbabilities(String age) {
		if (age.equalsIgnoreCase("young")) {
			return youngProbabilities;
		}
		else if (age.equalsIgnoreCase("average")) {
			return averageProbabilities;
		}
		else 
			return oldProbabilities;
	}
	
	public ArrayList<Float> getColor(String param) {
		return colors.get(param);
	}
	
	public HashMap<String, ArrayList<Float>> getAllColors() {
		return this.colors;
	}
	
	public String getColorName(String param) {
		return colorNames.get(param);
	}
	
	public HashMap<String, String> getAllColorNames() {
		return this.colorNames;
	}
	
	

}
